package model

import "time"

// WorkflowRun 工作流运行记录模型
type WorkflowRun struct {
	ID            uint64     `gorm:"primaryKey;column:id" json:"id"`
	WorkflowRunID string     `gorm:"column:workflow_run_id;type:varchar(64);not null;uniqueIndex" json:"workflow_run_id"`
	WorkflowID    string     `gorm:"column:workflow_id;type:varchar(64);not null" json:"workflow_id"`
	UserID        string     `gorm:"column:user_id;type:varchar(64);not null" json:"user_id"`
	Status        string     `gorm:"column:status;type:varchar(20);not null;default:running" json:"status"`
	StartedAt     time.Time  `gorm:"column:started_at;not null;default:CURRENT_TIMESTAMP" json:"started_at"`
	FinishedAt    *time.Time `gorm:"column:finished_at" json:"finished_at"`
	CreatedAt     time.Time  `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt     time.Time  `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"`
}

// TableName 指定表名
func (WorkflowRun) TableName() string {
	return "workflow_runs"
}

// Status constants
const (
	StatusRunning   = "running"
	StatusSucceeded = "succeeded"
	StatusFailed    = "failed"
)
